package com.wenc.psi.vmd;

import android.app.Application;


import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;

import com.wenc.psi.pojo.Part;
import com.wenc.psi.rpstr.PartRepository;

import java.util.List;

public class PartViewModel extends AndroidViewModel {

    private PartRepository partRepository;

    public PartViewModel(@NonNull Application application) {
        super(application);
        partRepository = new PartRepository(application);
    }

    public MutableLiveData<List<Part>> getPartLive() {
        return partRepository.getPartLive();
    }

    public void insert(Part... parts) {
        partRepository.insert(parts);
    }

    public void delete(Part... parts) {
        partRepository.delete(parts);
    }

    public void update(Part oldP, Part newP) {
        partRepository.update(oldP, newP);
    }

    public void clear(){
        partRepository.clear();
    }

    public void getDataBySearch(String input){
        partRepository.getDataBySearch(input);
    }

    public void getAllPart() {
        partRepository.getAllPart();
    }
}
